void _invertTree(struct TreeNode* root) {
    if (root) {
        struct TreeNode* tmp = root->left;
        root->left = root->right;
        root->right = tmp;
        _invertTree(root->left);
        _invertTree(root->right);
    }
}

struct TreeNode* invertTree(struct TreeNode* root) {
    _invertTree(root);
    return root;
}
